<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    ul {
      width: 80%;
      margin: 20px auto;
      height: 100px;
      display: flex;
      justify-content: space-around;
    }

    ul li {
      list-style: none;
      width: 200px;
      height: 100px;
      line-height: 100px;
      text-align: center;
      background: chartreuse;
      cursor: pointer;
      color: red;
    }

    ul .active {
      background: red;
      color: white;
      box-shadow: 4px 4px 4px blue;
    }
  </style>

<body>
  <ul>
    <li>首页</li>
    <li class="active">科技</li>
    <li>男人</li>
    <li>女人</li>
  </ul>
</body>
<script>
  window.onload = function () {
    var lis = document.getElementsByTagName("li");
    for (var i = 0; i < lis.length; i++) {
      lis[i].onclick = function () {
        //所有li元素移除active的class
        for (var j = 0; j < lis.length; j++) {
          lis[j].className = ""
        }
        // 让当前点击的li加上 active的class 
        this.className = "active";
      }
    }
  }
</script>

</html>